
function showLoading(text){
  wx.showLoading({
    title: text
  });
}

function hideLoading(){
  wx.hideLoading();
}

function showSuccess(text){
  wx.hideLoading();
  wx.showToast({
    title: text,
  });
}

function showFail(text){
  wx.hideLoading();
  showToast(text);
}

function showToast(text){
  wx.hideLoading();
  wx.showToast({
    title: text,
    icon: 'none'
  });
}

function goBack() {
  wx.navigateBack();
}

function saveAppValue(key, value) {
  wx.setStorageSync(key, value);
}

function getAppValue(key) {
  return wx.getStorageSync(key);
}

function stopRefresh() {
  wx.stopPullDownRefresh();
}

function showCommonModal(title,msg, callback) {
  wx.showModal({
    title: title,
    content: msg,
    showCancel: true,
    success(res) {
      callback(res)
    }
  })
}

module.exports = {
  showLoading,
  hideLoading,
  showSuccess,
  showFail,
  showToast,
  goBack,
  saveAppValue,
  getAppValue,
  stopRefresh,
  showCommonModal
}
